03. Demo: Feature Definition

Part 1

Cd13650 C5 L2 Demo 2 V2

Financial Data Feature Definition and Cleanup

This section explains crucial steps in using Pandas for financial data processing by defining features and handling gaps in datasets.

Key Steps:

  • Data Preparation:

    • Begin with clean data free of gaps.
  • Feature Definition:

    • Use popular technical indicators like moving averages and Bollinger Bands.
  • Moving Averages:

    • Calculate 5-day and 20-day moving averages using Pandas' rolling mean function.
    • Specify window size (5 or 20) for efficient computation.
  • Bollinger Bands:

    • Derive using a combination of moving averages and standard deviation.
    • Compute 20-day standard deviation with a rolling calculation.
    • Calculate upper band by adding twice standard deviation to moving average.
    • Calculate lower band by subtracting twice standard deviation from moving average.
  • Handling Null Values:

    • Remove any rows where there is not enough historical data to calculate your indicators of choice.
    • Validate data integrity after removing rows with null technical indicator values.

Following these structured steps enhances dataset readiness for further financial analysis and prediction.

Part 2

Cd13650 C5 L2 Demo 2b V2

Streamlined Feature Analysis with Pandas

Explore using Pandas for analyzing financial data through feature creation, visualization, and state space definition.

Key Steps:

  • Data Visualization:
    • Plot financial indicators to confirm accuracy.
    • Rotate labels for better readability on time-axis plots.
  • Feature Validation:
    • Moving Averages:
      • MA20 (Orange Line): Smoothly follows close price with less volatility.
      • MA5 (Green Line): Closely tracks the jagged close price - smoother than raw price, but more jagged than MA20.
    • Bollinger Bands:
      • Bands expand during high volatility.
  • State Space Definition:
    • Identify essential features for model prediction.
    • Use the close price, MA5, MA20, and Bollinger Bands as state space features.
  • Data Preparation:
    • Ensure cleaned, gap-free data before feature extraction.
    • Utilize Pandas for dataset refinement and transformation.

Completing these steps prepares the dataset for model building. Follow these guidelines for robust data analysis tasks.